class Solution(object):
    def minimizeResult(self, expression):
        s = expression.split('+')
        num1 = s[0]
        num2 = s[1]
        m1 = len(num1)
        m2 = len(num2)
        min_val = float('inf')
        for i in range(m1):
            add1 = int(num1[m1 - 1 - i: m1])
            if i < m1 - 1:
                c1 = int(num1[:m1 - 1 - i])
            else:
                c1 = 1
            for j in range(m2):
                add2 = int(num2[:j + 1])
                if j < m2 - 1:
                    c2 = int(num2[j + 1:])
                else:
                    c2 = 1
                val = c1 * c2 * (add1 + add2)
                if val < min_val:
                    min_val = val
                    min_expression = ''
                    if i < m1 - 1:
                        min_expression += str(c1)
                    min_expression += '(' + str(add1) + '+' + str(add2) + ')'
                    if j < m2 - 1:
                        min_expression += str(c2)
        return min_expression
